<template>
	<view class="container">
		<view class="list" v-for="item in List" @click="NewsInfo(item.ID)">
			<view class="icon"><image :src="Tools.GetImg(item.Img,200)" mode="aspectFill"></image></view>
			<view class="info">
				<view class="title">{{item.Title}}</view>
				<view class="date"><text space="ensp">{{item.From}}  {{Tools.ToTime(item.CreateDate)}}</text></view>
			</view>
		</view>
		<view class="nodata" v-if="NoData"></view>
		<view class="loadmore">{{Tip}}</view>
	</view>
</template>

<script>
	export default {
		onShareAppMessage: function() {
			var UserID = uni.getStorageSync("UserID");
		    return {
		      title: "资讯",
		      path: "pages/news/newslist?ParentID="+UserID//这是一个路径
		    }
		},
		data() {
			return {
				Tip:'正在加载...',
				Page:1,
				List:[],
				NoData:false,
				LoadMore:true,
				Keyword:'',
			};
		},
		onPullDownRefresh() {
			this.Re_Load();
		},
		onReachBottom() {
			if(this.LoadMore){
				this.Page++;
				this.Find_Pager();
			}
		},
		onLoad(options) {
			this.Util.SetParam(options); 
			this.Find_Pager();
		},
		methods:{
			NewsInfo(ID){
				uni.navigateTo({
					url:'/pages/news/newsinfo?ID='+ID
				})
			},
			Find_Pager(){
				var data={};
				data.Act="Find_News";
				data.Page=this.Page;
				data.Keyword=this.Keyword;
				data.Limit=20;
				this.Util.Loading("加载中...");
				this.Util.Post(data, json=>{
					this.Util.HideLoading();
					uni.stopPullDownRefresh();
					this.List= this.List.concat(json.Data.List);
					if(json.Data.Count==0){
						this.NoData=true;
						this.Tip="还没有任何资讯";
					}
					else if(this.List.length>=json.Data.Count){
						this.LoadMore=false;
						this.Tip="我是有底线的";
					}
				});
			},
			Re_Load(){
				this.List=[];
				this.Page=1;
				this.NoData=false;
				this.LoadMore=true;
				this.Tip='正在加载...';
				this.Find_Pager();
			}
		}
	}
</script>

<style lang="scss">
	.container{
		.list{width:100%; height:220rpx; padding:30rpx; margin-bottom:15rpx; display: flex; flex-direction: row; background-color: #ffffff;
			.icon{width:200rpx; height:160rpx; image{width:100%; height:100%;}}
			.info{flex:1; padding-left:20rpx;
				.title{width:100%; height:100rpx; line-height: 50rpx; font-size:40rpx; overflow: hidden;}
				.date{width:100%; font-size:30rpx; color:#a8a8a8; margin-top:20rpx;}
			}
		}
	}
</style>
